package com.ruoyi.web.controller.category;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.category.domain.SysTerrain;
import com.ruoyi.category.service.ISysTerrainService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地图Controller
 * 
 * @author yjf
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/category/terrain")
public class SysTerrainController extends BaseController
{
    @Autowired
    private ISysTerrainService sysTerrainService;

    /**
     * 查询地图列表
     */
    @PreAuthorize("@ss.hasPermi('category:terrain:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTerrain sysTerrain)
    {
        startPage();
        List<SysTerrain> list = sysTerrainService.selectSysTerrainList(sysTerrain);
        return getDataTable(list);
    }
    /**
     * 获取地图详细信息
     */
    @PreAuthorize("@ss.hasPermi('category:terrain:query')")
    @GetMapping(value = "/{terrainId}")
    public AjaxResult getInfo(@PathVariable("terrainId") Long terrainId)
    {
        return AjaxResult.success(sysTerrainService.selectSysTerrainByTerrainId(terrainId));
    }

    /**
     * 新增地图
     */
    @PreAuthorize("@ss.hasPermi('category:terrain:add')")
    @Log(title = "地图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTerrain sysTerrain)
    {
        return toAjax(sysTerrainService.insertSysTerrain(sysTerrain));
    }

    /**
     * 修改地图
     */
    @PreAuthorize("@ss.hasPermi('category:terrain:edit')")
    @Log(title = "地图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTerrain sysTerrain)
    {
        return toAjax(sysTerrainService.updateSysTerrain(sysTerrain));
    }

    /**
     * 删除地图
     */
    @PreAuthorize("@ss.hasPermi('category:terrain:remove')")
    @Log(title = "地图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{terrainIds}")
    public AjaxResult remove(@PathVariable Long[] terrainIds)
    {
        return toAjax(sysTerrainService.deleteSysTerrainByTerrainIds(terrainIds));
    }
}
